package com.gla.dao;

import com.gla.domain.Commodity;
import com.gla.domain.Shop;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SearchMapper {

    @Select("SELECT * FROM SHOP")
    List<Shop> selectAllAhop();

    @Select({"<script>" +
            "SELECT * FROM SHOP " +
            "where name LIKE " +
            "CONCAT('%',CONCAT(#{keyword},'%'))"+
            "or address LIKE " +
            "CONCAT('%',CONCAT(#{keyword},'%'))"+
            "or introduction LIKE " +
            "CONCAT('%',CONCAT(#{keyword},'%'))"+
            "</script>"
    })
    List<Shop> searchShop(String keyword);

    @Select("select * FROM COMMODITY WHERE P_O_U = 0 AND NAME LIKE CONCAT('%',CONCAT(#{keyword},'%'))")
    List<Commodity> searchPet(String keyword);

    @Select("select * FROM COMMODITY WHERE P_O_U = 1 AND NAME LIKE CONCAT('%',CONCAT(#{keyword},'%'))")
    List<Commodity> searchPetGoods(String keyword);

    @Select("select * from COMMODITY where type_id = #{type_id}")
    List<Commodity> getSearchFine(Integer type_id);
}
